const Sequelize = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  return CdSlide.init(sequelize, DataTypes);
}

class CdSlide extends Sequelize.Model {
  static init(sequelize, DataTypes) {
  super.init(
    {
      id: {
        type: DataTypes.CHAR(32),
        allowNull: false,
        primaryKey: true,
        comment: '文件md5值',
      },
      path: {
        type: DataTypes.STRING(128),
        allowNull: false,
        comment: '文件路径',
      },
      filename: {
        type: DataTypes.STRING(128),
        allowNull: false,
        comment: '文件名',
      },
      size: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '大小',
      },
      mtime: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '最后修改时间',
      },
      trained: {
        type: DataTypes.TINYINT,
        allowNull: false,
        comment: '是否添加到训练集',
      },
      detected: {
        type: DataTypes.TINYINT,
        allowNull: false,
        comment: '是否检测',
      },
      createTime: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
        comment: '从存储添加数据时间',
        field: 'create_time',
      },
      updateTime: {
        type: DataTypes.DATE,
        allowNull: true,
        comment: '数据更新时间',
        field: 'update_time',
      },
      deleteTime: {
        type: DataTypes.DATE,
        allowNull: true,
        comment: '数据删除时间',
        field: 'delete_time',
      },
      status: {
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 1,
        comment: '数据状态',
      },
    },
    {
      sequelize,
      tableName: 'cd_slide',
      timestamps: true,
      underscored: true,
      paranoid: true,
      createdAt: 'createTime',
      updatedAt: 'updateTime',
      deletedAt: 'deleteTime',
      indexes: [
        {
          name: 'PRIMARY',
          unique: true,
          using: 'BTREE',
          fields: [{ name: 'id' }],
        },
      ],
    },
  )
  return CdSlide;
  }
}
